﻿@model Forest.Lion.Web.Models.Candidate.CandidateListViewModel
@using Forest.Lion.Web.Extensions;
@using Forest.Lion.Web.Models;
@using Forest.Lion.Domain.Shared;
@using Forest.Lion.Model
@{
    ViewBag.Title = "应聘管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
    var defaultValue = '@ViewBag.DefaultKeyword';

    $(document).ready(function () {
        //表格隔行变色，最后一行没有边框
        $('.wrapContents table tbody tr:last-child td').css({ 'border-bottom': 'none' });
        $('.wrapContents table tbody tr:even').css({ 'background': '#f0f0f0' });
        $('.wrapContents table tbody tr:even').css({ 'background': '#fbfbfb' });

        //关键字输入框失去焦点
        $('#txtKeyword').bind('blur', function () {
            if (this.value == '') {
                this.value = defaultValue;
                this.className = "search_input";
            }
        });

        //关键字输入框获取焦点
        $('#txtKeyword').bind('focus', function () {
            if (this.value == defaultValue) {
                this.value = '';
            }
            this.className = "search_input_haveValue";
        });

        //过滤按钮点击事件
        $('#btnSearch').bind('click', function () {
            if ($('#txtKeyword').val() != defaultValue) {
                location.href = '@Url.Action("List")' + '?keyword=' + $('#txtKeyword').val() + '&queryStatus=' + $('#candidateQueryStatus').val();
            }
            else {
                alert('请输入关键字！');
            }
        });

        //初始化关键字输入框
        iniSearchTextBox(defaultValue);

        $('.chkAll').bind('click', function () {
            $('.itemChecked').attr('checked', $(this).attr('checked'));
        });

        //操作按钮点击事件
        $('.action').bind('click', function () {
            var label = $(this).val();
            if (!confirm("确定要" + label + "简历吗？")) {
                return false;
            }
        });

        //批处理操作按钮点击事件
        $('.batchAction').bind('click', function () {
            var label = $(this).val();
            if ($('.itemChecked:checked').length == 0) {
                alert("请选择要" + label + "的简历！");
                return false;
            }
            else {
                if (!confirm("确定要" + label + "所选简历吗？")) {
                    return false;
                }
            }
        });

        $('.restore').bind('click', function () {
            $('#hidSubmitId').val($(this).parent().find('#hidId').val());
            $('#btnRestore').click();
        });

        //设置弹出菜单
        $('.select').button({
            text: false,
            //text: "管理",
            icons: {
                primary: "ui-icon-triangle-1-s"
            }
        }).click(function () {
            //设置菜单状态
            var status = $(this).parent().find('#hidStatus').val();
            var lbtnReback = $('#lbtnReback');
            var lbtnInvited = $('#lbtnInvited');
            lbtnReback.show();
            lbtnInvited.show();


            $('#hidSubmitId').val($(this).parent().find('#hidId').val());

            var menu = $('#menuItem').show().position({
                my: "right top",
                at: "right bottom",
                of: this
            });

            $(document).one("click", function () {
                menu.hide();
            });

            return false;
        });

        $('#menuItem').hide().menu();

    });

    function iniSearchTextBox(defaultValue) {
        if ($('#txtKeyword').val() == "") {
            $('#txtKeyword').val(defaultValue);
        }
        $('#txtKeyword').toggleClass("search_input", $('#txtKeyword').val() == defaultValue);
        $('#txtKeyword').toggleClass("search_input_haveValue", $('#txtKeyword').val() != defaultValue);
    };
</script>
<div id="wrap">
    <div class="wrapContents">
        @using (Html.BeginForm())
        { 
            <input class="batchAction" type="submit" value="回复简历" id="btnRebackSelect" name="RebackSelect"
                style="display: none" />
            <input class="batchAction" type="submit" value="邀请面试" id="btnInvitedSelect" name="InvitedSelect"
                style="display: none" />
            <input class="batchAction" type="submit" value="删除" id="btnDeleteSelect" name="DeleteSelect"
                style="display: none" />
            <h1>
                应聘管理</h1>
            <div class="positions">
                @Html.ActionLink("所有简历", "List", new { queryStatus = CandidateQueryStatus.All }, new { @class = Model.CandidateQueryStatus == CandidateQueryStatus.All ? "cur" : "none" })
                @Html.ActionLink("未读简历(" + @Model.UnreadCount.ToString() + ")", "List", new { queryStatus = CandidateQueryStatus.Unread }, new { @class = Model.CandidateQueryStatus == CandidateQueryStatus.Unread ? "cur" : "none" })
                @Html.ActionLink("已浏览简历", "List", new { queryStatus = CandidateQueryStatus.Browsed }, new { @class = Model.CandidateQueryStatus == CandidateQueryStatus.Browsed ? "cur" : "none" })
                @Html.ActionLink("自选简历", "List", new { queryStatus = CandidateQueryStatus.Optional }, new { @class = Model.CandidateQueryStatus == CandidateQueryStatus.Optional ? "cur" : "none" })
                @Html.ActionLink("已邀请", "List", new { queryStatus = CandidateQueryStatus.Invited }, new { @class = Model.CandidateQueryStatus == CandidateQueryStatus.Invited ? "cur" : "none" })
                @Html.ActionLink("已回复", "List", new { queryStatus = CandidateQueryStatus.Replied }, new { @class = Model.CandidateQueryStatus == CandidateQueryStatus.Replied ? "cur" : "none" })
                @Html.ActionLink("已删除简历", "List", new { queryStatus = CandidateQueryStatus.Deleted }, new { @class = Model.CandidateQueryStatus == CandidateQueryStatus.Deleted ? "cur" : "none" })
            </div>
            <div class="search">
                <div class="search_left">
                    <div class="caozuo">
                        <a href="#" onclick="$('#btnDeleteSelected').click()">删除所选</a>
                    </div>
                    <div class="seachBox">
                        @Html.HiddenFor(x => x.CandidateQueryStatus)
                        @Html.TextBoxFor(x => x.Keyword, new { @class = "search_input", id = "txtKeyword" })
                        <input id="btnSearch" class="searchBtns" value="过滤" style="text-align: center" />
                    </div>
                    <div class="gjss">
                        <a href="#">高级搜索</a></div>
                    <div class="cl">
                    </div>
                </div>
                <div class="search_right">
                    @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
                </div>
                <div class="cr">
                </div>
            </div>
            <table cellpadding="0" cellspacing="0" width="100%" id="tblJobList">
                <thead>
                    <tr>
                        <th>
                            <input class="chkAll" type="checkbox" />
                        </th>
                        <th>
                            来源/求职信
                        </th>
                        <th>
                            应聘职位
                        </th>
                        <th>
                            姓名
                        </th>
                        <th>
                            年龄
                        </th>
                        <th>
                            工作经验
                        </th>
                        <th>
                            学历
                        </th>
                        <th>
                            简历刷新
                        </th>
                        <th>
                            联系电话
                        </th>
                        <th>
                            保存日期
                        </th>
                        <th>
                            标记
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody id="tbodyJobList">
                    @foreach (var item in Model.CandidateList)
                    {
                        <tr>
                            <td>
                                @Html.CheckBoxFor(x => item.IsChecked, new { @class = "itemChecked" })
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.SourceName)
                                @Html.DisplayFor(x => item.IsReadLetter)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.JobTitle)
                                @Html.DisplayFor(x => item.IsRecommend)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.FullName)
                                @Html.DisplayFor(x => item.TagName)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.Ages)
                                @Html.DisplayFor(x => item.Gender)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.YearsOfExperienceName)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.EducationLevelName)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.RefreshDate)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.Phone)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.LastUpdateDate)
                            </td>
                            <td>
                                @Html.DisplayFor(x => item.StatusName)
                            </td>
                            <td>
                                @Html.HiddenFor(x => item.Id, new { id = "hidId" })
                                <a href="#" class="restore">浏览</a>
                                <button class="select">
                                </button>
                            </td>
                        </tr>        
                    }
                </tbody>
            </table>
            <div class="pagelists">
                <div class="pagelists_btns">
                    <div class="allCheck">
                        <input class="chkAll" type="checkbox" /><span>全选</span>
                    </div>
                    <a href="#" onclick="$('#btnPostSelected').click()" class="fbsx">查看所选</a> <a href="#"
                        onclick="$('#btnPauseSelected').click()" class="fbsx">下载所选简历</a>
                </div>
                <div class="search_right">
                    @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
                </div>
                <div class="cr">
                </div>
            </div>
        }
        <ul id="menuItem" style="width: 70px; position: absolute; z-index: 100">
            <li><a href="#" id="lbtnPreview">预览</a></li>
            <li><a href="#" onclick="$('#btnReback').click()" id="lbtnReback">回复简历</a></li>
            <li><a href="#" onclick="$('#btnInvited').click()" id="lbtnInvited">邀请面试</a></li>
            <li><a href="#" onclick="$('#btnDelete').click()" id="lbtnDelete">删除</a></li>
        </ul>
        @using (Html.BeginForm(new { candidateQueryStatus = Model.CandidateQueryStatus, keyword = Model.Keyword }))
        {
            <input type="hidden" name="id" id="hidSubmitId" />
            <input type="hidden" name="keyword" id="hidSubmitKeyword" />
            <input class="action" type="submit" value="回复简历" id="btnReback" name="Reback" style="display: none" />
            <input class="action" type="submit" value="邀请面试" id="btnInvited" name="Invited" style="display: none" />
            <input class="action" type="submit" value="删除" id="btnDelete" name="Delete" style="display: none" />
        }
    </div>
</div>
